<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<title>Built-in Macro Functions</title>
<link rel="stylesheet" type="text/css" href="../../docs/ij.css" />
<link rel="shortcut icon" href="http://rsb.info.nih.gov/ij/favicon.ico">
</head>
<body bgcolor="#ffffff">

<font color="#224488">

<a name = Top></a>
<p class=navbar> <a href="../../index.html">home</a> | <a href="../../notes.html">news</a> | <a href="../../docs/index.html">docs</a> | <a href="../../download.html">download</a> | <a href="../../plugins/index.html">plugins</a> | <a href="../index.html">dev</a> | <a href="../../search.html">search</a> | <a href="../../links.html">links</a></p>
<h1>Built-in Macro Functions</h1>
</font>

<blockquote>

<hr>
<a href="#A">[&nbsp;A&nbsp;]</a><a href="#B">[&nbsp;B&nbsp;]</a><a
href="#C">[&nbsp;C&nbsp;]</a><a href="#D">[&nbsp;D&nbsp;]</a><a
href="#E">[&nbsp;E&nbsp;]</a><a href="#F">[&nbsp;F&nbsp;]</a><a
href="#G">[&nbsp;G&nbsp;]</a><a href="#H">[&nbsp;H&nbsp;]</a><a
href="#I">[&nbsp;I&nbsp;]</a><a href="#J">[&nbsp;J&nbsp;]</a><a
href="#K">[&nbsp;K&nbsp;]</a><a href="#L">[&nbsp;L&nbsp;]</a><a
href="#M">[&nbsp;M&nbsp;]</a>

<br><a href="#N">[&nbsp;N&nbsp;]</a><a href="#O">[&nbsp;O&nbsp;]</a><a
href="#P">[&nbsp;P&nbsp;]</a><a href="#Q">[&nbsp;Q&nbsp;]</a><a
href="#R">[&nbsp;R&nbsp;]</a><a href="#S">[&nbsp;S&nbsp;]</a><a
href="#T">[&nbsp;T&nbsp;]</a><a href="#U">[&nbsp;U&nbsp;]</a><a
href="#V">[&nbsp;V&nbsp;]</a><a href="#W">[&nbsp;W&nbsp;]</a><a
href="#X">[&nbsp;X&nbsp;]</a><a href="#Y">[&nbsp;Y&nbsp;]</a><a
href="#Z">[&nbsp;Z&nbsp;]</a>
<hr>
<p>
<a name="A"></a> A    <a href='#Top'>[&nbsp;Top&nbsp;]</a><p>
<a name=asin></a>
<b>abs(n)</b><br>

Returns the absolute value of <i>n</i>.
<p>

<a name=acos></a>
<b>acos(n)</b><br>
Returns the inverse cosine (in radians) of <i>n</i>.
<p>

<b>asin(n)</b><br>
Returns the inverse sine (in radians) of <i>n</i>.

<p>

<b>atan(n)</b><br>
Calculates the inverse tangent (arctangent) of <i>n</i>. Returns 
a value in the range -PI/2 through PI/2.
<p>

<b>atan2(y, x)</b><br>
Calculates the inverse tangent of <i>y/x</i> and returns an angle in the 
range -PI to PI, using the signs of the arguments 
to determine the quadrant. Multiply the result by 180/PI to convert to degrees.
<p>

<a name=autoUpdate></a>
<b>autoUpdate(boolean)</b><br>
If <i>boolean</i> is true, the display is refreshed each time lineTo(), drawLine(),  
drawString(), etc. are called, otherwise, the display is refreshed only when updateDisplay() 
is called or when the macro terminates.
<p>

 <b> B  </b><a name = B><a href='#Top'>[&nbsp;Top&nbsp;]</a><p>
<b>beep()</b><br>
Emits an audible beep.
<p>

<b>bitDepth() </b><br> 
Returns the bit depth of the active image: 8, 16, 24 (RGB) or 32 (float).

<p>
 <b> C  </b><a name = C><a href='#Top'>[&nbsp;Top&nbsp;]</a><p>
<a name=calibrate></a>
<b>calibrate(value)</b><br>
Uses the calibration function of the active image to convert a raw pixel value 
to a density calibrated value.  The argument must be an integer in the range 0-255 
(for 8-bit images) or 0-65535 (for 16-bit images). Returns the same value if the active 
image does not have a calibration function.
<p>

<a name=call></a>
<b>call("class.method", arg1, arg2, ...)</b><br>
Calls a public static method in a Java class, passing an arbitrary number
of string arguments, and returning a string. Refer to the
<a href="http://rsb.info.nih.gov/ij/macros/CallJavaDemo.txt">CallJavaDemo</a> macro
and the <a href="http://rsb.info.nih.gov/ij/plugins/imp-props.html">ImpProps</a>
plugin for examples. Note that the call() function does not work when ImageJ is 
running as an unsigned applet.
<p>

<b>changeValues(v1, v2, v3)</b><br>
Changes pixels in the image or selection that have a value in the range <i>v1</i>-<i>v2</i> 
to <i>v3</i>. For example, <i>changeValues(0,5,5)</i> changes all pixels less than 5 to 5, 
and <i>changeValues(0x0000ff,0x0000ff,0xff0000)</i> changes all blue pixels in an RGB image to red.
<p>

<b>charCodeAt(string, index)</b><br>
Returns the Unicode value of the character at the specified index in <i>string</i>. 
Index values can range from 0 to lengthOf(<i>string</i>). Use the fromCharCode() function
to convert one or more Unicode characters to a string.
<p>

<b>close()</b><br>
Closes the active image.  This function has the advantage of not closing the "Log"
or "Results" window when you meant to close the active image.
<p>

<b>cos(angle)</b><br>

Returns the cosine of an angle (in radians).
<p>


 <b> D  </b><a name = D><a href='#Top'>[&nbsp;Top&nbsp;]</a><p>

<a name=d2s></a>
<b>d2s(n, decimalPlaces)</b><br>
Converts the number <i>n</i> into a string using the specified number of decimal places.
Note that d2s stands for "double to string".
This function will probably be replaced by one with a better name.
<p>

<a name=dialog></a>
<b>Dialog.create("Title")</b><br>
Creates a dialog box with the specified title. Call <i>Dialog.addString()</i>, <i>Dialog.addNumber(),</i> etc. to 
add components to the dialog. Call <i>Dialog.show()</i> to display the dialog and <i>Dialog.getString()</i>, 

<i>Dialog.getNumber()</i>, etc. to retrieve the values entered by the user.
Refer to the
<a href="http://rsb.info.nih.gov/ij/macros/DialogDemo.txt">DialogDemo</a>
macro for an example.
<p>
<blockquote>

<b>Dialog.addMessage(string)</b> - 
Adds a message to the dialog.</i> The message can be broken into multiple
lines by inserting new line characters ("\n") into the string.
<br>
<b>Dialog.addString("Label", "Initial text")</b> -
Adds a text field to the dialog, using the specified label and initial text.
<br>
<b>Dialog.addString("Label", "Initial text", columns)</b> -
Adds a text field to the dialog, where <i>columns</i> specifies the field 
width in characters.
<br>
<b>Dialog.addNumber("Label", default)</b> -
Adds a numeric field to the dialog, using the specified label and default value.
<br>
<b>Dialog.addNumber("Label", default, decimalPlaces, columns, units)</b> -
Adds a numeric field, using the specified label and default value. <i>DecimalPlaces</i>
specifies the number of digits to right of decimal point, <i>columns</i> specifies the the field 
width in characters and <i>units</i> is a string that is displayed to 
the right of the field.
<br>
<b>Dialog.addCheckbox("Label", default)</b> -
Adds a checkbox to the dialog, using the specified label and default state (true or false).
<br>
<b>Dialog.addCheckboxGroup(rows, columns, labels, defaults)</b> -
Adds a <i>rows</i>x<i>columns</i> grid of checkboxes to the dialog, using the specified labels and default states
(<a href="http://rsb.info.nih.gov/ij/macros/AddCheckboxGroupDemo.txt">example</a>).
Requires 1.41c.
<br>
<b>Dialog.addChoice("Label", items)</b> -
Adds a popup menu to the dialog, where <i>items</i> is a string array containing the menu items.
<br>
<b>Dialog.addChoice("Label", items, default)</b> -
Adds a popup menu, where <i>items</i> is a string array containing the choices
and <i>default</i> is the default choice.

<br>
<b>Dialog.show()</b> -
Displays the dialog and waits until the user clicks "OK" or "Cancel". The macro 
terminates if the user clicks "Cancel".
<br>
<b>Dialog.getString()</b> -
Returns a string containing the contents of the next text field.
<br>
<b>Dialog.getNumber()</b> -
Returns the contents of the next numeric field.
<br>
<b>Dialog.getCheckbox()</b> -
Returns the state (true or false) of the next checkbox.
<br>

<b>Dialog.getChoice()</b> -
Returns the selected item (a string) from the next popup menu.
<br>

</blockquote>

<b>doCommand("Command")</b><br>
Runs an ImageJ menu command in a separate thread and returns immediately. As an example, 
<i>doCommand("Start Animation")</i> starts animating the current stack in a separate 
thread and the macro continues to execute. Use <i>run("Start Animation")</i> and the 
macro hangs until the user stops the animation.
<p>

<b>doWand(x, y)</b><br>
Equivalent to clicking on the current image at (x,y) with the wand tool.
Note that some objects, especially one pixel wide lines,
may not be reliably traced unless they have been thresholded (highlighted in red) 
using <a href="#setThreshold">setThreshold</a>.

<p>

<b>drawLine(x1, y1, x2, y2)</b><br>
Draws a line between (x1, y1) and (x2, y2). Use setColor() to 
specify the color of the line and setLineWidth() to vary the line width.
<p>

<a name=drawOval></a>
<b>drawOval(x, y, width, height)</b><br>
Draws the outline of an oval using the current color and line width.
See also: 
<a href="#fillOval">fillOval</a>, 
<a href="#setColor">setColor</a>, 
<a href="#setLineWidth">setLineWidth</a>, 
<a href="#autoUpdate">autoUpdate</a>.
<p>

<a name=drawRect></a>
<b>drawRect(x, y, width, height)</b><br>
Draws the outline of a rectangle using the current color and line width.
See also: 
<a href="#fillRect">fillRect</a>, 
<a href="#setColor">setColor</a>, 
<a href="#setLineWidth">setLineWidth</a>, 
<a href="#autoUpdate">autoUpdate</a>.
<p>

<a name=drawString></a>
<b>drawString("text", x, y)</b><br>
Draws text at the specified location. 
Call <a href="#setFont">setFont()</a>
to specify the font.
Call <a href="#setJustification">setJustification()</a>
to have the text centered or right justified.
Call <a href="#getStringWidth">getStringWidth()</a> to get the width of the
text in pixels.
Refer to the
<a href="http://rsb.info.nih.gov/ij/macros/TextDemo.txt">TextDemo</a> macro for examples.
<p>

<b>dump()</b><br>

Writes the contents of the symbol table, the tokenized macro code and the variable stack to the "Log" window.
<p>


 <b> E  </b><a name = E><a href='#Top'>[&nbsp;Top&nbsp;]</a><p>
<a name=endsWith></a>
<b>endsWith(string, suffix)</b><br>
Returns <i>true</i> (1) if <i>string</i> ends with <i>suffix</i>.
See also: 
<a href="#startsWith">startsWith</a>, 
<a href="#indexOf">indexOf</a>,
<a href="#substring">substring</a>,
<a href="#matches">matches</a>. 
<p>

<a name=eval></a>
<b>eval(macro)</b><br>
Evaluates (runs) one or more lines of macro code.
See also: 
<a href="http://rsb.info.nih.gov/ij/macros/EvalDemo.txt">EvalDemo</a> macro and
<a href="#runMacro">runMacro</a> function.
<p>

<b>eval("script", javascript)</b><br>
Evaluates the JavaScript code contained in the string <i>javascript</i>, for example
<i>eval("script","IJ.getInstance().setAlwaysOnTop(true);")</i>. Mac users, and users of 
Java 1.5, must have a copy of
<a href="http://rsb.info.nih.gov/ij/download/tools/JavaScript.jar">JavaScript.jar</a>
in the plugins folder. Requires 1.41m.
<p>

<a name=exec></a>
<b>exec(string or strings)</b><br>
Executes a native command and returns the output of that command
as a string. Also opens Web pages in the default browser and documents
in other applications (e.g., Excel). Refer to the 
<a href="http://rsb.info.nih.gov/ij/macros/ExecExamples.txt">ExecExamples</a>
macro for examples. Requires 1.39c.
<p>

<b>exit() or exit("error message")</b><br>
Terminates execution of the macro and, optionally, displays an error message. 
<p>

<b>exp(n)</b><br>
Returns the exponential number e (i.e., 2.718...) raised to the power of <i>n</i>.
<p>

<a name=ext></a>
<b>Ext (Macro Extension) Functions</b><br>
These are functions that have been added to the macro language by plugins using
the MacroExtension interface. As an example, the
<a href="http://rsb.info.nih.gov/ij/plugins/5d-extensions.html">Image5D_Extensions</a>
plugin adds functions that work with the Image5D plugins, such as <i>Ext.setDisplayMode("color")</i>
and <i>Ext.setChannel(ch)</i>.
<p>

 <b> F  </b><a name = F><a href='#Top'>[&nbsp;Top&nbsp;]</a><p>
<a name=file></a>
 <b>File Functions</b><br>
These functions allow you to get information about a file, read or write a text file,
create a directory, or to delete, rename or move a file or directory.
The
<a href="http://rsb.info.nih.gov/ij/macros/FileDemo.txt">FileDemo</a>
macro demonstrates how to use them.
See also: 
<a href="#getDirectory">getDirectory</a> and
<a href="#getFileList">getFileList</a>.
<p>
<blockquote>

<b>File.append(string, path)</b> - 
Appends <i>string</i> to the end of the specified file.
Requires 1.41j.
<br>

<b>File.close(f)</b> - 
Closes the specified file, which must have been opened using File.open().
<br>

<b>File.dateLastModified(path)</b> - 
Returns the date and time the specified file was last modified.<br>

<b>File.delete(path)</b> - 
Deletes the specified file or directory. With v1.41e or later, returns "1" (true)
if the file or directory was successfully deleted.
If the file is a directory, it must be empty.
The file must be in the user's home directory,  the ImageJ directory
or the temp directory.
<br>

<b>File.directory</b> - 
The directory path of the last file opened using open(), saveAs(),
File.open() or File.openAsString(). Requires 1.38q.<br>

<b>File.exists(path)</b> - 
Returns "1" (true) if the specified file exists.<br>

<b>File.getName(path)</b> - 
Returns the last name in <i>path</i>'s name  sequence.<br>

<b>File.getParent(path)</b> - 
Returns the parent of the file specified by <i>path</i>.<br>

<b>File.isDirectory(path)</b> - 
Returns "1" (true) if the specified file is a directory.<br>

<b>File.lastModified(path)</b> - 
Returns the time the specified file was last modified as
the number of milliseconds since January 1, 1970.<br>

<b>File.length(path)</b> - 
Returns the length in bytes of the specified file.<br>

<b>File.makeDirectory(path)</b> - 
Creates a directory.<br>

<b>File.name</b> - 
The name of the last file opened using open(), saveAs(),
File.open() or File.openAsString(). Requires 1.38q.<br>

<a name=Fileopen></a>
<b>File.open(path)</b> - 
Creates a new text file and returns a file variable that refers to it. To write to the file, 
pass the file variable to the
<a href="#print">print</a> function.
Displays a file save dialog box if <i>path</i> is an empty string.
The file is closed when the macro exits.
Currently, only one file can be open at a time.
For an example, refer to the
<a href="http://rsb.info.nih.gov/ij/macros/SaveTextFileDemo.txt">SaveTextFileDemo</a> macro.
<br>

<b>File.openAsString(path)</b> - 
Opens a text file and returns the contents as a string. Displays a file 
open dialog box if <i>path</i> is an empty string. 
Use <i>lines=split(str,"\n")</i> to convert the string to
an array of lines.
<br>

<b>File.openAsRawString(path)</b> - 
Opens a file and returns the first 5,000 bytes as a string. Returns up to
10 megabytes if the name ends with ".txt". Refer to the
<a href="http://rsb.info.nih.gov/ij/macros/First10Bytes.txt">First10Bytes</a>
and
<a href="http://rsb.info.nih.gov/ij/macros/ZapGremlins.txt">ZapGremlins</a>
macros for examples. Requires 1.39f.
<br>

<b>File.openUrlAsString(url)</b> - 
Opens a URL and returns the contents as a string. Returns an emptly
string if the host or file cannot be found. With v1.41i and later, returns "&lt;Error: message&gt;"
if there any error, including host or file not found.
<br>

<b>File.openDialog(title)</b> - 
Displays a file open dialog and returns the path to the
file choosen by the user
(<a href="http://rsb.info.nih.gov/ij/macros/OpenDialogDemo.txt">example</a>). 
The macro exits if
the user cancels the dialog.
Requires 1.39d.
<br>

<b>File.rename(path1, path2)</b> - 
Renames, or moves, a file or directory. Returns "1" (true) if successful.
Requires 1.38b.
<br>

<b>File.saveString(string, path)</b> - 
Saves <i>string</i> as a file. Requires 1.41j.
<br>

<b>File.separator</b> - 
Returns the file name separator character ("/" or "\").<br>
<p>

</blockquote>

<b>fill()</b><br>
Fills the image or selection with the current drawing color.
<p>

<a name=fillOval></a>
<b>fillOval(x, y, width, height)</b><br>
Fills an oval bounded by the specified rectangle with the current drawing color.
See also: 
<a href="#drawOval">drawOval</a>, 
<a href="#setColor">setColor</a>, 
<a href="#autoUpdate">autoUpdate</a>.
<p>

<a name=fillRect></a>
<b>fillRect(x, y, width, height)</b><br>
Fills the specified rectangle with the current drawing color. 
See also: 
<a href="#drawRect">drawRect</a>, 
<a href="#setColor">setColor</a>, 
<a href="#autoUpdate">autoUpdate</a>.
<p>

<a name=Fit></a>
 <b>Fit Functions</b><br>
 These functions do curve fitting.
The
<a href="http://rsb.info.nih.gov/ij/macros/examples/CurveFittingDemo.txt">CurveFittingDemo</a>
macro demonstrates how to use them.
Requires 1.41k.
<blockquote>

<b>Fit.doFit(equation, xpoints, ypoints)</b> - 
Fits the specified equation to the points defined by <i>xpoints</i>, <i>ypoints</i>. <i>Equation</i>
can be either the equation name or an index. The equation names are shown in the drop down menu
 in the <i>Analyze&gt;Tools&gt;Curve Fitting</i> window.
<br>

<b>Fit.rSquared</b> - 
Returns R^2=1-SSE/SSD, where SSE is the sum of the squares of the errors and
SSD is the sum of the squares of the deviations about the mean.
<br>

<b>Fit.p(index)</b> - 
Returns the specified parameter.
<br>

<b>Fit.nParams</b> - 
Returns the number of parameters.
<br>

<b>Fit.f(x)</b> - 
Returns the y value at <i>x</i>.
<br>

<b>Fit.nEquations</b> - 
Returns the number of equations.
<br>

<b>Fit.getEquation(index, name, formula)</b> - 
Gets the name and formula of the specified equation.
<br>

<b>Fit.plot</b> - 
Plots the current curve fit.
<br>

</blockquote>

<b>floodFill(x, y)</b><br>
Fills,  with the foreground color, pixels that are connected to, 
and the same color as, the pixel at <i>(x, y)</i>. With 1.37e or later, 
does 8-connected filling if  there is an optional string argument containing "8", 
for example <i>floodFill(x, y, "8-connected")</i>.
This function is used to implement the 
<A href="http://rsb.info.nih.gov/ij/macros/tools/FloodFillTool.txt">flood fill (paint bucket)</a> macro tool.
<p>

<a name=floor></a>
<b>floor(n)</b><br>
Returns the largest value that is not greater than
<i>n</i> and is equal to an integer.
See also: 
<a href="#round">round</a>. 
<p>

<b>fromCharCode(value1,...,valueN)</b><br>
This function takes one or more Unicode values and returns a string. 
<p>


 <b> G  </b><a name = G><a href='#Top'>[&nbsp;Top&nbsp;]</a><p>
<a name=getArgument></a>
<b>getArgument()</b><br>

Returns the string argument passed to macros called by <a href="#runMacro">runMacro(macro, arg)</a>, 
<a href="#eval">eval(macro)</a>, 
<i>IJ.runMacro(macro, arg)</i> or <i>IJ.runMacroFile(path, arg)</i>.
<p>

<b>getBoolean("message")</b><br>
Displays a dialog box containing the specified message and "Yes", "No" and "Cancel" buttons. 
Returns <i>true</i> (1) if the user clicks "Yes", returns <i>false</i> (0) if the user clicks
"No" and exits the macro if the user clicks "Cancel".

<p>

<b>getBoundingRect(x, y, width, height)</b><br>
Replace by <a href="#getSelectionBounds">getSelectionBounds</a>.
<p>

<b>getCursorLoc(x, y, z, modifiers)</b><br>
Returns the cursor location in pixels and the mouse event modifier flags.
The <i>z</i> coordinate is zero for 2D images. For stacks, it is one less than the 
slice number. For examples, see the
<a href="http://rsb.info.nih.gov/ij/macros//GetCursorLocDemo.txt">GetCursorLocDemo</a>  and the

<a href="http://rsb.info.nih.gov/ij/macros/tools/GetCursorLocDemoTool.txt">GetCursorLocDemoTool</a> macros.
<p>

<a name=getDateAndTime></a>
<b>getDateAndTime(year, month, dayOfWeek, dayOfMonth, hour, minute, second, msec)</b><br>
Returns the current date and time.
For an example, refer to the
<a href="http://rsb.info.nih.gov/ij/macros/GetDateAndTime.txt">GetDateAndTime</a> macro.
See also: <a href="#getTime">getTime</a>.
<p>

<a name=getDimensions></a>
<b>getDimensions(width, height, channels, slices, frames)</b><br>
Returns the dimensions of the current image.
Requires 1.38s.
<p>

 <a name=getDirectory></a>
<b>getDirectory(string)</b><br>
Displays a "choose directory" dialog and returns the selected directory, or returns
the path to a specified directory, such as "plugins", "home", etc.
The returned path ends with a file separator, either "\" (Windows) or "/".
Returns an empty string if the specified directory is not found or 
aborts the macro if the user cancels the "choose directory" dialog box.
For examples, see the
<a href="http://rsb.info.nih.gov/ij/macros/GetDirectoryDemo.txt">GetDirectoryDemo</a> and
<a href="http://rsb.info.nih.gov/ij/macros/ListFilesRecursively.txt">ListFilesRecursively</a> macros.
See also: <a href="#getFileList">getFileList</a> and the <a href="#file">File functions</a>.

<blockquote>

<b>getDirectory("Choose a Directory")</b> - 
Displays a file open dialog, using the argument as a title, and
returns the path to the directory selected by the user.<br>
<b>getDirectory("plugins")</b> - 
Returns the path to the plugins directory.<br>
<b>getDirectory("macros")</b> - 
Returns the path to the macros directory.<br>
<b>getDirectory("image")</b> - 
Returns the path to the directory that the active image was loaded from.<br>
<b>getDirectory("startup")</b> - 
Returns the path to the directory that ImageJ was launched from (usually the ImageJ directory).<br>
<b>getDirectory("home")</b> - 
Returns the path to users home directory.<br>
<b>getDirectory("temp")</b> - 
Returns the path to the temporary directory (/tmp on Linux and Mac OS X).<br>
</blockquote>

<a name=getFileList></a>
<b>getFileList(directory)</b><br>
Returns an array containing the names of the files in the specified directory path. 
The names of subdirectories have a "/" appended.
For an example, see the
<a href="http://rsb.info.nih.gov/ij/macros/ListFilesRecursively.txt">ListFilesRecursively</a> macro.
<p>

<a name=getHeight></a>
<b>getHeight()</b><br>
Returns the height in pixels of the current image.
<p>

<b>getHistogram(values, counts, nBins[, histMin, histMax])</b><br>
Returns the histogram of the current image or selection.  <i>Values</i> is an array that will 
contain the pixel values for each of the histogram counts (or the bin starts for 16 and 32 bit images), or set this argument to 0.
<i>Counts</i> is an array that
will contain the histogram counts. <i>nBins</i> is the number of bins that will be used. 
It must be 256 for 8 bit and RGB image, or an integer 
greater than zero for 16 and 32 bit images. With 16-bit images, the <i>Values</i> argument
is ignored if <i>nBins</i> is 65536.
With 16-bit and 32-bit images, and ImageJ 1.35a and later, the histogram range can be specified
using optional <i>histMin</i> and <i>histMax</i> arguments.
See also: 
<a href="#getStatistics">getStatistics</a>,
<a href="http://rsb.info.nih.gov/ij/macros/HistogramLister.txt">HistogramLister</a>,
<a href="http://rsb.info.nih.gov/ij/macros/HistogramPlotter.txt">HistogramPlotter</a>,
<a href="http://rsb.info.nih.gov/ij/macros/StackHistogramLister.txt">StackHistogramLister</a> and
<a href="http://rsb.info.nih.gov/ij/macros/CustomHistogram.txt">CustomHistogram</a>.
<p>

<b>getImageID()</b><br>
Returns the unique ID (a negative number) of the active image. Use the <i>selectImage(id)</i>, 
<i>isOpen(id)</i> and <i>isActive(id)</i> functions to activate an image or to determine if 
it is open or active. 

<p>

<a name=getImageInfo></a>
<b>getImageInfo()</b><br>
Returns a string containing the text that would
be displayed by the <i>Image&gt;Show Info</i> command. 
To retrieve the contents of a text window, use 
<a HREF="#getInfo">getInfo("window.contents")</a>. 
For an example, see the
<a HREF="http://rsb.info.nih.gov/ij/macros/ListDicomTags.txt">ListDicomTags</a> macros.
See also: <a href="#getMetadata">getMetadata</a>.
<p>

<a name=getInfo></a>
<b>getInfo("window.contents")</b><br>
If the front window is a text window, returns the contents of that window. 
If the front window is an image, returns a string containing the text that would
be displayed by <i>Image&gt;Show Info</i>.  Note that 
<a HREF="#getImageInfo">getImageInfo()</a>
is a more reliable way to retrieve information about an image.
Use split(getInfo(),'\n') to break the string returned by this function into separate lines.
Replaces the getInfo() function.
Requires 1.38m.
<p>

<b>getInfo("image.description")</b><br>
Returns the TIFF image description tag, or an empty string
if this is not a TIFF image or the image description is not
available.
Requires 1.39t.
<p>

<b>getInfo("image.subtitle")</b><br>
Returns the subtitle of the current image. This is the line of
information displayed above the image and below the title bar.
Requires 1.38m.
<p>

<a name=getInfo-label></a>
<b>getInfo("slice.label")</b><br>
Return the label of the current stack slice. This is the string that 
appears in parentheses in the subtitle, the line of information 
above the image. Returns an empty
string if the current image is not a stack or the current
slice does not have a label.
Requires 1.38m.
<p>

<a name=getInfo-java></a>
<b>getInfo(key)</b><br>
Returns the Java property associated with the specified key (e.g., "java.version",
"os.name", "user.home", "user.dir", etc.). Returns an empty string if there is
no value associated with the key.
See also:
<a href="#getList-properties">getList("java.properties")</a>.
Requires 1.38m.
<p>

<a name=getLine></a>
<b>getLine(x1, y1, x2, y2, lineWidth)</b><br>
Returns the starting coordinates, ending coordinates and width of the current straight line 
selection. The coordinates and line width are in pixels.
Sets x1 = -1 if there is no line selection.
Refer to the
<a HREF="http://rsb.info.nih.gov/ij/macros/GetLineDemo.txt">GetLineDemo</a> macro for an example.
See also: <a href="#makeLine">makeLine</a>.<p>

<a name=getList-titles></a>
<b>getList("window.titles")</b><br>
Returns a list (array) of non-image window titles.
For an example, see the
<a href="http://rsb.info.nih.gov/ij/macros/DisplayWindowTitles.txt">DisplayWindowTitles</a> macro.
Requires 1.38m.
<p>

<a name=getList-properties></a>
<b>getList("java.properties")</b><br>
Returns a list (array) of Java property keys.
For an example, see the
<a HREF="http://rsb.info.nih.gov/ij/macros/DisplayJavaProperties.txt">DisplayJavaProperties</a> macro.
See also:
<a href="#getInfo-java">getInfo(key)</a>.
Requires 1.38m.
<p>

<a name=getLocationAndSize></a>
<b>getLocationAndSize(x, y, width, height)</b><br>
Returns the location and size, in screen coordinates, of the active image window. Use 
<a href="#getWidth">getWidth</a> and
<a href="#getHeight">getHeight</a>
to get the width and height, in image coordinates, of the active image.
See also:
<a href="#setLocation">setLocation</a>,
<p>

<b>getLut(reds, greens, blues)</b><br>
Returns three arrays containing the red, green and blue intensity values from the
current lookup table. See the
<a href="http://rsb.info.nih.gov/ij/macros/LookupTables.txt">LookupTables</a>
macros for examples.
<p>

<a name=getMetadata></a>
<b>getMetadata("Info")</b><br>
Returns the metadata (a string) from the "Info" property of the current image.
With DICOM images, this is the information (tags) in the DICOM header.
See also: <a href="#setMetadata">setMetadata</a>. 
Requires 1.40b.
<p>

<b>getMetadata("Label")</b><br>
Returns the current slice label.
The first line of the this label (up to 60 characters) is display
as part of the image subtitle. 
With DICOM stacks, returns the metadata from the DICOM header.
See also: <a href="#setMetadata">setMetadata</a>. 
Requires 1.40b.
<p>

<b>getMinAndMax(min, max)</b><br>
Returns the minimum and maximum displayed pixel values (display range).
See the
<a href="http://rsb.info.nih.gov/ij/macros/DisplayRangeMacros.txt">DisplayRangeMacros</a>
for examples.

<p>

<b>getNumber("prompt", defaultValue)</b><br>
Displays a dialog box and returns the number entered by the user. 
The first argument is the prompting message and the second is the value initially 
displayed in the dialog. Exits the macro if the user clicks on "Cancel" in the dialog.
Returns <i>defaultValue</i> if the user enters an invalid number.
See also: <a href="#dialog">Dialog.create</a>. 
<p>

<a name=getPixel></a>
<b>getPixel(x, y)</b><br>
Returns the value of the pixel at <i>(x,y)</i>. Note that pixels in RGB images
contain red, green and blue components that need to be extracted using shifting
and masking. See the <a href="http://rsb.info.nih.gov/ij/macros/tools/ColorPickerTool.txt">Color Picker Tool</a>
macro for an example that shows how to do this.
<p>

<a name=getPixelSize></a>
<b>getPixelSize(unit, pixelWidth, pixelHeight)</b><br>
Returns the unit of length (as a string) and the pixel dimensions.
For an example, see the
<a href="http://rsb.info.nih.gov/ij/macros/ShowImageInfo.txt">ShowImageInfo</a> macro.
See also: <a href="#getVoxelSize">getVoxelSize</a>. 
<p>

<b>getProfile()</b><br>
Runs <i>Analyze&gt;Plot Profile</i> (without displaying the plot) and returns the 
intensity values as an array. For an example, see the

<a href="http://rsb.info.nih.gov/ij/macros/GetProfileExample.txt">GetProfileExample</a> macro.
<p>

<a name=getRawStatistics></a>
<b>getRawStatistics(nPixels, mean, min, max, std, histogram)</b><br>
This function is similar to <a href="#getStatistics">getStatistics</a> except that the values 
returned are uncalibrated and the histogram of
16-bit images has a bin width of one and is returned as a <i>max</i>+1 element array.
For examples, refer to the
<a href="http://rsb.info.nih.gov/ij/macros/ShowStatistics.txt">ShowStatistics</a> macro set.
See also: 
<a href="#calibrate">calibrate</a>.
<p>


<a name=getResult></a>
<b>getResult("Column", row)</b><br>
Returns a measurement from the ImageJ results table or NaN if the
specified column is not found. The first 
argument specifies a column in the table. It must be a
"Results" window column label, such as "Area", "Mean" or "Circ.".
The second argument specifies the row, where 0&lt;=<i>row</i>&lt;nResults.
<i>nResults</i> is a predefined variable that contains the current measurement 
count. (Actually, it's a built-in function with the "()" optional.) With ImageJ 1.34g and later,
you can omit the second argument and have the row default to 
nResults-1 (the last row in the results table).
See also: 
<a href="#nResults">nResults</a>,
<a href="#setResult">setResult</a>,

<a href="#isNaN">isNaN</a>,
<a href="#getResultLabel">getResultLabel</a>. 
<p>

<a name=getResultLabel></a>
<b>getResultLabel(row)</b><br>
Returns the label of the specified row in the results table, or an empty
string if <i>Display Label</i> is not checked in <i>Analalyze&gt;Set Measurements</i>. 
<p>

<a name=getSelectionBounds></a>
<b>getSelectionBounds(x, y, width, height)</b><br>
Returns the smallest rectangle that can completely contain the current selection. <i>x</i> and <i>y</i> 
are the pixel coordinates of the upper left corner of the rectangle. <i>width</i> and <i>height</i> are the width and 
height of the rectangle in pixels. If there is no selection, 
returns (0, 0, ImageWidth, ImageHeight). 
See also: <a href="#selectionType">selectionType</a> and
<a href="#setSelectionLocation">setSelectionLocation</a>. 
<p>

<b>getSelectionCoordinates(xCoordinates, yCoordinates)</b><br>
Returns two arrays containing the X and Y coordinates of the points that define the current 
selection. See the
<a href="http://rsb.info.nih.gov/ij/macros/SelectionCoordinates.txt">SelectionCoordinates</a>
macro for an example.
See also:

<a href="#selectionType">selectionType</a>,
<a href="#getSelectionBounds">getSelectionBounds</a>. 
<p>

<a name=getSliceNumber></a>
<b>getSliceNumber()</b><br>
Returns the number of the currently displayed stack image, an integer between 1 and 
<a href="#nSlices">nSlices</a>.  Returns 1 if the active image is not a stack. 
See also:
<a href="#setSlice">setSlice</a>. 
<p>

<a name=getStatistics></a>
<b>getStatistics(area, mean, min, max, std, histogram)</b><br>
Returns the area, average pixel value, minimum pixel value,
maximum pixel value, standard deviation of the pixel values 
and histogram of the active image or selection. The histogram 
is returned  as a 256 element array. For 8-bit and RGB
images, the histogram bin width is one. For 16-bit and 32-bit images,
the bin width is (<i>max</i>-<i>min</i>)/256.
For examples, refer to the
<a href="http://rsb.info.nih.gov/ij/macros/ShowStatistics.txt">ShowStatistics</a> macro set.
Note that trailing arguments can be omitted. For example, you can use <i>getStatistics(area)</i>, 
<i>getStatistics(area, mean)</i> or <i>getStatistics(area, mean, min, max)</i>.
See also: 
<a href="#getRawStatistics">getRawStatistics</a>
<p>

<b>getString("prompt", "default")</b><br>
Displays a dialog box and returns the string entered by the user. 
The first argument is the prompting message and the second is the initial 
string value. Exits the macro if the user clicks on "Cancel" or enters an empty string.
See also: <a href="#dialog">Dialog.create</a>. 
<p>

<a name=getStringWidth></a>
<b>getStringWidth(string)</b><br>
Returns the width in pixels of the specified string. 
See also: <a href="#setFont">setFont</a>, <a href="#drawString">drawString</a>. 
Requires v1.41d.
<p>

<a name=getThreshold></a>
<b>getThreshold(lower, upper)</b><br>
Returns the lower and upper threshold levels. Both variables are set to -1 
if the active image is not thresholded.
See also:
<a href="#setThreshold">setThreshold</a>, 
<a href="#getThreshold">getThreshold</a>, 
<a href="#resetThreshold">resetThreshold</a>. 
 <p>

<a name=getTime></a>
<b>getTime()</b><br>
Returns the current time in milliseconds. The granularity of the time varies considerably 
from one platform to the next.  On Windows NT, 2K, XP it is about 10ms.  On other Windows
versions it can be as poor as 50ms.  On many Unix platforms, including Mac OS X,  it 
actually is 1ms.
See also: <a href="#getDateAndTime">getDateAndTime</a>.
<p>

<b>getTitle()</b><br>
Returns the title of the current image.
<p>

<a name=getVoxelSize></a>
<b>getVoxelSize(width, height, depth, unit)</b><br>
Returns the voxel size and unit of length ("pixel", "mm", etc.) of the current 
image or stack.
See also: <a href="#getPixelSize">getPixelSize</a>, <a href="#setVoxelSize">setVoxelSize</a>.
<p>

<a name=getVersion></a>
<b>getVersion()</b><br>
Returns the ImageJ version number as a string (e.g., "1.34s").
See also: 
<a href="#requires">requires</a>.
<p>

<a name=getWidth></a>
<b>getWidth()</b><br>
Returns the width in pixels of the current image.<p>

<b>getZoom()</b><br>
Returns the magnification of the active image, a number in the range 0.03125 to 32.0
(3.1% to 3200%).
<p>

 <b> I  </b><a name = I><a href='#Top'>[&nbsp;Top&nbsp;]</a><p>

<a name=imageCalculator></a>
<b>imageCalculator(operator, img1, img2)</b><br>
Runs the <i>Process&gt;Image Calculator</i> tool, where

<i>operator</i> ("add","subtract","multiply","divide", "and", "or", "xor", "min", "max", "average", "difference" or "copy") 
specifies the operation, and <i>img1</i> and <i>img2</i> specify the operands. <i>img1</i> and <i>img2</i> can be
either an image title (a string) or an image ID (an integer). The <i>operator</i> string can include up to three modifiers: 
"create" (e.g., "add create") causes the result to
be stored in a new window, "32-bit" causes the result to be 32-bit floating-point 
and "stack" causes the entire stack to be processed.
See the <a href="http://rsb.info.nih.gov/ij/macros/ImageCalculatorDemo.txt">ImageCalculatorDemo</a> macros for examples.
<p>

<a name=indexOf></a>
<b>indexOf(string, substring)</b><br>
Returns the index within <i>string</i> of the first occurrence of
<i>substring</i>.
See also: 
<a href="#lastIndexOf">lastIndexOf</a>,
<a href="#startsWith">startsWith</a>, 
<a href="#endsWith">endsWith</a>,
<a href="#substring">substring</a>,
<a href="#toLowerCase">toLowerCase</a>, 
<a href="#replace">replace</a>,
<a href="#matches">matches</a>. 
<p>

<b>indexOf(string, substring, fromIndex)</b><br>
Returns the index within <i>string</i> of the first occurrence of
<i>substring</i>, with the search starting at <i>fromIndex</i>.
<p>

<b>is("Applet")</b><br>
Returns <i>true</i> if ImageJ is running as an applet.
Requires v1.39p.
<p>

<b>is("Batch Mode")</b><br>
Returns <i>true</i> if the macro interpreter is running in batch mode.
Requires v1.39p.
<p>

<b>is("Caps Lock Set")</b><br>
Returns <i>true</i> if the caps lock key is set. Always return <i>false</i>
on some platforms.
Requires v1.42e.
<p>

<b>is("Composite")</b><br>
Returns <i>true</i> if the current image is a a multi-channel
stack that uses the CompositeImage class.
Requires v1.39r.
<p>

<b>is("Inverting LUT")</b><br>
Returns <i>true</i> if the current image is using an inverting lookup table.
<p>

<b>is("Hyperstack")</b><br>
Returns <i>true</i> if the current image is a hyperstack.
Requires v1.39k.
<p>

<b>is("Locked")</b><br>
Returns <i>true</i> if the current image is locked.
<p>

<b>is("Virtual Stack")</b><br>
Returns <i>true</i> if the current image is a virtual stack.
Requires v1.39q.
<p>

<b>isActive(id)</b><br>
Returns <i>true</i> if the image with the specified ID is active.
<p>

<a name=isKeyDown></a>
<b>isKeyDown(key)</b><br>
Returns <i>true</i> if the specified key is pressed, where <i>key</i> must be "shift", "alt" or "space".
See also: 
<a href="#setKeyDown">setKeyDown</a>.
<p>

<a name=isNaN></a>
<b>isNaN(n)</b><br>
Returns <i>true</i> if the value of the number <i>n</i> is NaN (Not-a-Number).
A common way to create a NaN is to divide zero by zero. This function is
required because (n==NaN) is always false.
Note that the numeric constant NaN is predefined in the macro language.
<p>

<b>isOpen(id)</b><br>

Returns <i>true</i> if the image with the specified ID is open.
<p>

<b>isOpen("Title")</b><br>
Returns <i>true</i> if the window with the specified title is open.
<p>


<a name=J></a><a name=K></a>
 <b> L  </b><a name = L><a href='#Top'>[&nbsp;Top&nbsp;]</a><p>
<a name=lastIndexOf></a>
<b>lastIndexOf(string, substring)</b><br>
Returns the index within <i>string</i> of the rightmost occurrence of
<i>substring</i>.
See also: 
<a href="#indexOf">indexOf</a>,
<a href="#startsWith">startsWith</a>, 
<a href="#endsWith">endsWith</a>,
<a href="#substring">substring</a>. 
<p>

<a name=lengthOf></a>
<b>lengthOf(str)</b><br>
Returns the length of a string or array.
<p>

<b>lineTo(x, y)</b><br>
Draws a line from current location to (<i>x,y</i>) .
<p>

<a name=List></a>
 <b>List Functions</b><br>
 These functions work with a list of key/value pairs.
The
<a href="http://rsb.info.nih.gov/ij/macros/ListDemo.txt">ListDemo</a>
macro demonstrates how to use them.
Requires 1.41f.
<blockquote>

<b>List.set(key, value)</b> - 
Adds a key/value pair to the list.
<br>

<b>List.get(key)</b> - 
Returns the value associated with <i>key</i>, or
an empty string if the key is not found.<br>

<b>List.size()</b> - 
Returns the size of the list.<br>

<b>List.clear()</b> - 
Resets the list.<br>

<b>List.setList(list)</b> - 
Loads the key/value pairs in <i>list</i>.<br>

<b>List.getList()</b> - 
Returns the list as a string.<br>

</blockquote>

<b>log(n)</b><br>
Returns the natural logarithm (base e) of <i>n</i>. Note that log10(n) = log(n)/log(10).

<p>


 <b> M  </b><a name = M><a href='#Top'>[&nbsp;Top&nbsp;]</a><p>

<b>makeLine(x1, y1, x2, y2)</b><br>
Creates a new straight line selection. The origin (0,0) is assumed to be the upper left 
corner of the image. Coordinates are in pixels. With ImageJ 1.35b and letter, you can create
segmented line selections by specifying more than two coordinate pairs, for example
<i>makeLine(25,34,44,19,69,30,71,56)</i>. 
<p>

<a name=makeLine></a>
<b>makeLine(x1, y1, x2, y2, lineWidth)</b><br>
Creates a straight line selection with the specified width. Requires 1.38u.
See also: <a href="#getLine">getLine</a>.
<p>

<b>makeOval(x, y, width, height)</b><br>
Creates an elliptical selection, where (<i>x,y</i>) define the upper left 
corner of the bounding rectangle of the ellipse.
<p>

<b>makePoint(x, y)</b><br>
Creates a point selection at the specified location. Create
a multi-point selection by using
<i>makeSelection("point",xpoints,ypoints)</i>.  Use <i>setKeyDown("shift"); makePoint(x, y);</i> to add a point
to an existing point selection.
<p>

<b>makePolygon(x1, y1, x2, y2, x3, y3, ...)</b><br>
Creates a polygonal selection. At least three coordinate pairs must be specified, 
but not more than 200. As an example, <i>makePolygon(20,48,59,13,101,40,75,77,38,70)</i>
creates a polygon selection with five sides.
<p>

<b>makeRectangle(x, y, width, height)</b><br>
Creates a rectangular selection. The <i>x</i> and <i>y</i> arguments are the coordinates 
(in pixels) of the upper left corner of the selection. The origin (0,0) of the 
coordinate system is the upper left corner of the image.
<p>

<b>makeSelection(type, xcoord, ycoord)</b><br>
Creates a selection from a list of XY coordinates. The first argument should be
"polygon", "freehand", "polyline", "freeline", "angle" or "point". In ImageJ 1.32g or later,
it can also be the numeric value returned by <a href="#selectionType">selectionType</a>.
The <i>xcoord</i> and <i>ycoord</i> arguments
are numeric arrays that contain the X and Y coordinates.
See the <a href="http://rsb.info.nih.gov/ij/macros/MakeSelectionDemo.txt">MakeSelectionDemo</a>
macro for examples.
<p>

<a name=matches></a>
<b>matches(string, regex)</b><br>
Returns <i>true</i> if <i>string</i> matches the specified 
<a href="http://en.wikipedia.org/wiki/Regular_expression">regular expression</a>.
See also: 
<a href="#startsWith">startsWith</a>, 
<a href="#endsWith">endsWith</a>, 
<a href="#indexOf">indexOf</a>,
<a href="#replace">replace</a>. 
Requires v1.39r.
<p>

<b>maxOf(n1, n2)</b><br>
Returns the greater of two values.
<p>

<b>minOf(n1, n2)</b><br>
Returns the smaller of two values.
<p>

<b>moveTo(x, y)</b><br>
Sets the current drawing location. The origin is always assumed to be the upper 
left corner of the image.
<p>


 <b> N  </b><a name = N><a href='#Top'>[&nbsp;Top&nbsp;]</a><p>

<b>newArray(size)</b><br>
Returns a new array containing <i>size</i> elements.  
You can also create arrays by listing the 
elements, for example newArray(1,4,7) or newArray("a","b","c").
For more examples, see the

<a href="http://rsb.info.nih.gov/ij/macros/Arrays.txt">Arrays</a> macro.
<p>
The ImageJ macro language does not directly support 2D arrays. As a work around, 
either create a blank image and use setPixel() and getPixel(), or 
create a 1D array using a=newArray(xmax*ymax) and do your own 
indexing (e.g., value=a[x+y*xmax]).
<p>

<b>newImage(title, type, width, height, depth)</b><br>
Opens a new image or stack using the name <i>title</i>.
The string <i>type</i> should contain
"8-bit", "16-bit", "32-bit" or "RGB". In addition, it can contain "white", "black" or "ramp" (the default is "white").
As an example, use "16-bit ramp" to create a 16-bit image containing a grayscale ramp.
<i>Width</i> and <i>height</i> specify the width and height of the image in pixels. 
<i>Depth</i> specifies the number of stack slices.
<p>

<b>newMenu(macroName, stringArray)</b><br>
Defines a menu that will be added to the toolbar when the menu tool
named <i>macroName</i> is installed. Menu tools are macros with
names ending in "Menu Tool".
<i>StringArray</i> is an array containing the menu commands.
Returns a copy of <i>stringArray</i>. For an example, refer to the
<a href="http://rsb.info.nih.gov/ij/macros/toolsets/Menus.txt">Menus</a>
toolset.
Requires v1.38b or later.
<p>

<b>nImages</b><br>
Returns number of open images. The parentheses "()" are optional. 
<p>

<a name=nResults></a>
<b>nResults</b><br>
Returns the current measurement counter value. The parentheses "()" are optional.
<p>

<a name=nSlices></a>

<b>nSlices</b><br>
Returns the number of images in the current stack. Returns 1 if the current image is not a stack.
The parentheses "()" are optional.
See also: 
<a href="#getSliceNumber">getSliceNumber</a>,
<p>


 <b> O  </b><a name = O><a href='#Top'>[&nbsp;Top&nbsp;]</a><p>

<b>open(path)</b><br>
Opens and displays a tiff, dicom, fits, pgm, jpeg, bmp, gif, lut, 
roi, or text file. Displays an error message and aborts the macro
if the specified file is not in one of the supported formats, 
or if the file is not found. 
Displays a file open dialog box if
<i>path</i> is an empty string or if there is no argument.
Use the <i>File&gt;Open</i> command with the command recorder running
to generate calls to this function.
With 1.41k or later, opens images specified by a URL, for example
<i>open("http://rsb.info.nih.gov/ij/images/clown.gif").</i>
<p>


 <b> P  </b><a name = P><a href='#Top'>[&nbsp;Top&nbsp;]</a><p>
<a name=parseFloat></a>
<b>parseFloat(string)</b><br>
Converts the string argument to a number and returns it. Returns NaN (Not a Number) if the
string cannot be converted into a number. Use the
<a HREF="#isNaN">isNaN()</a> function to test for NaN.
For examples, see
<a href="http://rsb.info.nih.gov/ij/macros/ParseFloatIntExamples.txt">ParseFloatIntExamples</a>.
<p>

<a name=parseInt></a>
<b>parseInt(string)</b><br>
Converts <i>string</i> to an integer and returns it. Returns NaN if the
string cannot be converted into a integer.

<p>

<b>parseInt(string, radix)</b><br>
Converts <i>string</i> to an integer and returns it. 
The optional second argument (<i>radix</i>) specifies the base of the number 
contained in the string.
The radix must be an integer between 2 and 36. For radixes above 10, 
the letters of the alphabet indicate numerals greater than 9. Set <i>radix</i> to 16 to parse hexadecimal numbers.
Returns NaN if the string cannot be converted into a integer. For examples, see
<a href="http://rsb.info.nih.gov/ij/macros/ParseFloatIntExamples.txt">ParseFloatIntExamples</a>.
<p>

<a name=Plot></a>
<b>Plot.create("Title", "X-axis Label", "Y-axis Label", xValues, yValues)</b><br>
Generates a plot using the specified title, axis labels and X and Y coordinate arrays.
If only one array is specified it is assumed to contain the Y values and a 0..n-1 sequence is used
as the X values. It is also permissible to specify no arrays and use <i>Plot.setLimits()</i> and <i>Plot.add()</i> to generate the plot.
Use <i>Plot.show()</i> to display the plot in a window or it will be displayed automatically when
the macro exits.
For examples, check out the
<a href="http://rsb.info.nih.gov/ij/macros/ExamplePlots.txt">ExamplePlots</a> macro file.
<p>

<b>Plot.setLimits(xMin, xMax, yMin, yMax)</b><br>
Sets the range of the x-axis and y-axis of plots created using <i>Plot.create()</i>.
Must be called immediately after Plot.create().<p>

<b>Plot.setLineWidth(width)</b><br>
Specifies the width of the line used to draw a curve. Points (circle, box, etc.) are also drawn larger if a line width greater than one is specified. 
Note that the curve specified in <i>Plot.create()</i>
is the last one drawn before the plot is dispayed or updated.<p>

<b>Plot.setColor("red")</b><br>

Specifies the color used in subsequent calls to <i>Plot.add()</i> or <i>Plot.addText()</i>. 
The argument can be
"black", "blue", "cyan", "darkGray", "gray", "green", "lightGray", 
"magenta", "orange", "pink", "red", "white" or "yellow".  
Note that the curve specified in <i>Plot.create()</i> is drawn last.
<p>

<b>Plot.add("circles", xValues, yValues)</b><br>
Adds a curve, set of points or error bars to a plot created using <i>Plot.create()</i>.
If only one array is specified it is assumed to contain the Y values and a 0..n-1 sequence is used
as the X values. The first argument can be "line", "circles", "boxes", "triangles", "crosses", "dots", 
"x" or "error bars".
<p>

<b>Plot.addText("A line of text", x, y)</b><br>
Adds text to the plot at the specified location, where (0,0)
is the upper left corner of the the plot frame and (1,1) is the lower right corner. Call
<i>Plot.setJustification()</i> to have the text centered or right justified.
<p>

<b>Plot.setJustification("center")</b><br>
Specifies the justification used by <i>Plot.addText()</i>.
The argument can be "left", "right" or "center". The default is "left".
<p>

<b>Plot.show()</b><br>
Displays the plot generated by <i>Plot.create()</i>, <i>Plot.add()</i>, etc. in a window. 
This function is automatically called when a macro exits.
<p>

<b>Plot.update()</b><br>
Draws the plot generated by <i>Plot.create()</i>, <i>Plot.add()</i>, etc. in an existing plot window. 
Equivalent to <i>Plot.show()</i> if no plot window is open.
<p>

<b>Plot.getValues(xpoints, ypoints)</b><br>
Returns the values displayed by clicking on "List" in a plot or histogram window
(<a href="http://rsb.info.nih.gov/ij/macros/examples/PlotGetValuesDemo.txt">example</a>).
Requires 1.41k. 
<p>

<b>pow(base, exponent)</b><br>
Returns the value of <i>base</i> raised to the power of <i>exponent</i>.
<p>

<a name=print></a>
<b>print(string)</b><br>
Outputs a string to the "Log" window. Numeric arguments are automatically converted to strings.
Starting with ImageJ v1.34b, print() accepts multiple arguments. For example, you can use
<i>print(x,y,width, height)</i> instead of <i>print(x+" "+y+" "+width+" "+height)</i>.
If the first argument is a file handle returned by <a href="#Fileopen">File.open(path)</a>, then the second 
is saved in the refered file
(see <a href="http://rsb.info.nih.gov/ij/macros/SaveTextFileDemo.txt">SaveTextFileDemo</a>).
<p>
Numeric expressions are automatically converted to strings using four decimal places, or use the 
<a href="#d2s">d2s</a> function to
specify the decimal places. For example, <i>print(2/3)</i> outputs "0.6667" but <i>print(d2s(2/3,1))</i> outputs "0.7".
<p>
Starting with ImageJ 1.37j, print() accepts commands such as <i>"\\Clear"</i>, 
<i>"\\Update:&lt;text&gt;"</i> and <i>"\\Update&lt;n&gt;:&lt;text&gt;"</i> (for n<26)
that clear the "Log"  window and update its contents. For example,
<i>print("\\Clear")</i> erases the Log window, <i>print("\\Update:new text")</i> replaces the
last line with "new text" and
<i>print("\\Update8:new 8th line")</i> replaces the 8th line with "new 8th line". Refer to the 
<a href="http://rsb.info.nih.gov/ij/macros/LogWindowTricks.txt">LogWindowTricks</a> macro
for an example.
<p>
Starting with ImageJ 1.38m, the second argument to print(arg1, arg2) is appended to a text window or table
if the first argument is a window title in brackets, for example <i>print("[My Window]", "Hello, world")</i>. With text windows, 
newline characters ("\n") are not automatically appended and
text that starts with <i>"\\Update:"</i> replaces the entire contents of the window.
Refer to the
<a href="http://rsbweb.nih.gov/ij/macros/PrintToTextWindow.txt">PrintToTextWindow</a>, 
<a href="http://rsbweb.nih.gov/ij/macros/Clock.txt">Clock</a> and 
<a href="http://rsbweb.nih.gov/ij/macros/ProgressBar.txt">ProgressBar</a>
macros for examples.
<p>
The second argument to print(arg1, arg2) is appended to a table (e.g., ResultsTable)
if the first argument is the title of the table in brackets. Use the <i>Plugins&gt;New </i>command
to open a blank table. Any command that can be
sent to the "Log" window (<i>"\\Clear"</i>, <i>"\\Update:&lt;text&gt;" </i>, etc.)
can also be sent to a table.
Refer to the
<a href="http://rsbweb.nih.gov/ij/macros/SineCosineTable.txt">SineCosineTable</a> and
<a href="http://rsbweb.nih.gov/ij/macros/TableTricks.txt">TableTricks</a>
macros for examples.
<p>

<a name=Q></a>
 <b> R  </b><a name = R><a href='#Top'>[&nbsp;Top&nbsp;]</a><p>
<b>random</b><br>
Returns a random number between 0 and 1.
<p>

<b>rename(name)</b><br>
Changes the title of the active image to the string <i>name</i>.
<p>

<a name=replace></a>
<b>replace(string, old, new)</b><br>
Returns the new string that results from replacing all occurrences of
<i>old</i> in <i>string</i> with <i>new</i>, where <i>old</i> and <i>new</i> 
are single character strings. If <i>old</i> or <i>new</i> are longer than
one character, each substring of 
<i>string</i> that matches the 
<a href="http://en.wikipedia.org/wiki/Regular_expression">regular expression</a>
<i>old</i> is replaced with <i>new</i>.
See also:
<a href="#matches">matches</a>. 
<p>

<a name=requires></a>
<b>requires("1.29p")</b><br>
Display a message and aborts the macro if the ImageJ version is less than the one specified.
See also: 
<a href="#getVersion">getVersion</a>.

<p>

<a name=reset></a>
<b>reset</b><br>
Restores the backup image created by the
<a href="#snapshot">snapshot</a> function.
Note that reset() and run("Undo") are basically the same, so
only one run() call can be reset.
<p>

<b>resetMinAndMax</b><br>
With 16-bit and 32-bit images, resets the minimum and maximum displayed pixel values (display range)
to be the same as the current image's minimum and maximum pixel values.
With 8-bit images, sets the display range to 0-255.
With RGB images, does nothing.
See the
<a href="http://rsb.info.nih.gov/ij/macros/DisplayRangeMacros.txt">DisplayRangeMacros</a>
for examples.
<p>

<a name=resetThreshold></a>
<b>resetThreshold</b><br>
Disables thresholding.
See also: 
<a href="#setThreshold">setThreshold</a>, 
<a href="#setAutoThreshold">setAutoThreshold</a>, 
<a href="#getThreshold">getThreshold</a>.
<p>

<b>restorePreviousTool</b><br>
Switches back to the previously selected tool. Useful for 
creating a tool macro that
<a href="http://rsb.info.nih.gov/ij/developer/macro/macros.html#action">performs an action</a>,
such as opening a file,
when the user clicks on the tool icon.
<p>

<b>restoreSettings</b><br>
Restores <i>Edit/Options</i> submenu settings saved by 
the <i>saveSettings()</i> function.
<p>

<a name=roiManager></a>
<b>roiManager(cmd)</b><br>
Runs an ROI Manager command, where <i>cmd</i> must be
"Add", "Add & Draw", "Update", "Delete", "Deselect", "Measure", "Draw", 
"Fill", "Label", "Combine", "Split", "Sort", "Reset" or "Multi Measure". 
The ROI Manager is opened if it is not already open.
Use <i>roiManager("reset")</i> to delete all items on the list.
Use 
<a href="#setOption"">setOption("Show All", boolean)</a>
to enable/disable "Show All" mode.
For examples, refer to the
<a href="http://rsb.info.nih.gov/ij/macros/RoiManagerMacros.txt">RoiManagerMacros</a>,
<a href="http://rsb.info.nih.gov/ij/macros/RoiManagerAddParticles.txt">RoiManagerAddParticles</a> and
<a href="http://rsb.info.nih.gov/ij/macros/ROI_Manager_Stack_Demo.txt">ROI Manager Stack Demo</a>
macros.
<p>

<b>roiManager(cmd, name)</b><br>
Runs an ROI Manager I/O command, where <i>cmd</i> is
"Open", "Save or "Rename", and <i>name</i> is a file path or name. 
The "Save" option ignores selections and
saves all the ROIs as a ZIP archive. With ImageJ 1.38o and later,
it displays a file save dialog if <i>name</i> is "". The "Rename" option requires
v1.37h or later. With v1.37i or later, you can get the selection name
using <i>call("ij.plugin.frame.RoiManager.getName", index)</i>.
The ROI Manager is opened if it is not already open.
<p>

<b>roiManager("count")</b><br>
Returns the number of items in the ROI Manager list.
<p>

<b>roiManager("index")</b><br>
Returns the index of the currently selected item on the ROI Manager list, or
-1 if the list is empty, no items are selected, or more than one item is selected.
<p>

<b>roiManager("select", index)</b><br>
Selects an item in the ROI Manager list, where
<i>index</i> must be greater than or equal zero and less than the
value returned by <i>roiManager("count")</i>.
Use <i>roiManager("deselect") </i> to deselect all items on the list.
For an example, refer to the
<a href="http://rsb.info.nih.gov/ij/macros/ROI_Manager_Stack_Demo.txt">ROI Manager Stack Demo</a> macro.
<p>

<a name=round></a>
<b>round(n)</b><br>
Returns the closest integer to <i>n</i>.
See also: 
<a href="#floor">floor</a>. 
<p>

<b>run("command"[, "options"])</b><br>
Executes an ImageJ menu command. The optional second argument contains values that 
are automatically entered into dialog boxes (must be GenericDialog or OpenDialog). Use
the Command Recorder (<i>Plugins&gt;Macros&gt;Record</i>) to generate run() function calls.
Use string concatentation to pass a variable as an argument. For examples, see the

<a href="http://rsb.info.nih.gov/ij/macros/ArgumentPassingDemo.txt">ArgumentPassingDemo</a> macro.
<p>

<a name=runMacro></a>
<b>runMacro(name)</b><br>
Runs the specified macro file, which is assumed to be in the
Image macros folder. A full
file path may also be used.  The ".txt" extension is optional.
Returns any string argument returned by the macro. May have
an optional second string argument that is passed to macro. 
For an example, see the
<a href="http://rsb.info.nih.gov/ij/macros/CalculateMean.txt">CalculateMean</a> macro.
See also: 
<a href="#eval">eval</a> and
<a href="#getArgument">getArgument</a>.
<p>


 <b> S  </b><a name = S><a href='#Top'>[&nbsp;Top&nbsp;]</a><p>

<b>save(path)</b><br>
Saves an image, lookup table, selection or text window to the specified file path.  The path must end in 
".tif", ".jpg", ".gif", ".zip", ".raw", ".avi", ".bmp", ".fits", ".png", ".pgm", ".lut", ".roi" or ".txt".
<p>

<b>saveAs(format, path)</b><br>
Saves the active image, lookup table, selection, measurement results, selection XY coordinates 
or text window  to the specified file path.  The <i>format</i> argument
must be "tiff", "jpeg", "gif", "zip", "raw", "avi", "bmp", "fits", "png", "pgm", "text image", "lut", "selection",
"measurements", "xy Coordinates" or "text". Use <i>saveAs(format)</i> to
have a "Save As" dialog displayed.
<p>

<b>saveSettings()</b><br>
Saves most <i>Edit/Options</i> submenu settings so they can be 
restored later by calling <i>restoreSettings()</i>.
<p>

<a name=screenHeight></a>
<b>screenHeight</b><br>
Returns the screen height in pixels. 
See also: 
<a href="#getLocationAndSize">getLocationAndSize</a>,
<a href="#setLocation">setLocation</a>.
<p>

<a name=screenWidth></a>
<b>screenWidth</b><br>
Returns the screen width in pixels. 
<p>

<a name=selectionName></a>
<b>selectionName</b><br>
Returns the name of the current selection, or an empty string 
if the selection does not have a name.
Aborts the macro if there is no selection.
See also:
<a href="#setSelectionName">setSelectionName</a> and

<a href="#selectionType">selectionType</a>. 
<p>

<a name=selectionType></a>
<b>selectionType() </b><br> 
Returns the selection type, where 0=rectangle, 1=oval, 2=polygon, 3=freehand, 4=traced, 
5=straight line, 6=segmented line, 7=freehand line, 8=angle, 9=composite and 10=point. 
Returns -1 if there is no selection. For an example, see the
<a href="http://rsb.info.nih.gov/ij/macros/ShowImageInfo.txt">ShowImageInfo</a> macro.
<p>

<b>selectImage(id)</b><br>
Activates the image with the specified ID (a negative number). If <i>id</i> is greater than zero, 
activates the <i>id</i>th image listed in the Window menu. With ImageJ 1.33n and later, <i>id</i>
can be an image title (a string). 
<p>

<b>selectWindow("name")</b><br>
Activates the image window with the title "name". Also activates non-image windows in v1.30n or later.
<p>

<a name=setAutoThreshold></a>
<b>setAutoThreshold()</b><br>
 Sets the threshold levels based on an analysis of the histogram of 
 the current image or selection. Equivalent to clicking on "Auto" in
the <i>Image&gt;Adjust&gt;Threshold </i>window. 
See also: 
<a href="#setThreshold">setThreshold</a>, 
<a href="#getThreshold">getThreshold</a>, 
<a href="#resetThreshold">resetThreshold</a>. 
<p>
 
 <b>setBackgroundColor(r, g, b)</b><br>
Sets the background color, where <i>r</i>, <i>g</i>, and <i>b</i> are &gt;= 0 and &lt;= 255.

<p>

<a name=setBatchMode></a>
<b>setBatchMode(arg)</b><br>
If <i>arg</i> is <i>true</i>, the interpreter enters batch mode and images are not displayed, 
allowing the macro to run up to 20 times faster. If <i>arg</i> is <i>false</i>, exits batch mode
and displays the active image in a window.
ImageJ exits batch mode when the macro terminates
if there is no <i>setBatchMode(false)</i> call.
Note that a macro should not call <i>setBatchMode(true)</i>
more than once.
<p>
With ImageJ 1.37j or later, set <i>arg</i> to <i>"exit and display"</i> to exit
batch mode and display all open batch mode images.
Here are five example batch mode macros:
<a href="http://rsb.info.nih.gov/ij/macros/BatchModeTest.txt">BatchModeTest</a>,
<a href="http://rsb.info.nih.gov/ij/macros/BatchMeasure.txt">BatchMeasure</a>,
<a href="http://rsb.info.nih.gov/ij/macros/BatchSetScale.txt">BatchSetScale</a>,
<a href="http://rsb.info.nih.gov/ij/macros/ReplaceRedWithMagenta.txt">ReplaceRedWithMagenta</a>.
<p>

<a name=setColor></a>
<b>setColor(r, g, b)</b><br>
Sets the drawing color, where <i>r</i>, <i>g</i>, and <i>b</i> are &gt;= 0 and &lt;= 255.
With 16 and 32 bit images, sets the color to 0 if r=g=b=0. With 16 and 32 bit images, 
use <i>setColor(1,0,0)</i> to make the drawing color the same is the minimum 
displayed pixel value.
SetColor() is faster than 
<a href="#setForegroundColor">setForegroundColor()</a>, and it does not change
 the system wide foreground color or repaint the color picker tool icon, but it cannot be
used to specify the color used by commands called from macros, for example <i>run("Fill")</i>.
<p>

<b>setColor(value)</b><br>
Sets the drawing color. For 8 bit images, 0&lt;=<i>value</i>&lt;=255.
For 16 bit images, 0&lt;=<i>value</i>&lt;=65535. For RGB images, use hex 
constants (e.g., 0xff0000 for red). This function does not change the foreground color used
by <i>run("Draw")</i> and <i>run("Fill")</i>.
<p>

<a name=setFont></a>
<b>setFont(name, size[, style])</b><br>
The first argument is the font name. It should be "SansSerif", "Serif" or "Monospaced".
The second argument is the point size of the font. The optional third argument is a
string containing "bold" or "italic", or both. With ImageJ 1.37e or later, the third argument
can also contain the keyword "antialiased".
For examples, run the

<a href="http://rsb.info.nih.gov/ij/macros/TextDemo.txt">TextDemo</a> macro.
<p>

<a name=setForegroundColor></a>
<b>setForegroundColor(r, g, b)</b><br>
Sets the foreground color, where <i>r</i>, <i>g</i>, and <i>b</i> are &gt;= 0 and &lt;= 255.
See also: 
<a href="#setColor">setColor</a>.
<p>

<a name=setJustification></a>
<b>setJustification("center")</b><br>
Specifies the justification used by <i>drawString()</i> and <i>Plot.addText()</i>.
The argument can be "left", "right" or "center". The default is "left".
<p>

<a name=setKeyDown></a>
<b>setKeyDown(keys)</b><br>
Simulates pressing the shift, alt or space keys, where
<i>keys</i> is a string containing some combination of "shift", "alt" or "space".
Any key not specified is set "up". Use <i>setKeyDown("none")</i> to set all keys in the
"up" position. With ImageJ 1.38e or later, call <i>setKeyDown("esc")</i> to abort the currently
running macro or plugin.
For examples, see the
<a href="http://rsb.info.nih.gov/ij/macros/CompositeSelections.txt">CompositeSelections</a>,
<a href="http://rsb.info.nih.gov/ij/macros/DoWandDemo.txt">DoWandDemo</a> and
<a href="http://rsb.info.nih.gov/ij/macros/tools/AbortMacroActionTool.txt">AbortMacroActionTool</a> macros.
See also: 
<a href="#isKeyDown">isKeyDown</a>.
<p>

<a name=setLineWidth></a>
<b>setLineWidth(width)</b><br>
Specifies the line width (in pixels) used by drawLine(), lineTo(), drawRect() and drawOval().

<p>

<a name=setLocation></a>
<b>setLocation(x, y)</b><br>
Moves the active image window to a new location.
With v1.39e or later, moves the active window.
See also: 
<a href="#getLocationAndSize">getLocationAndSize</a>,
<a href="#screenWidth">screenWidth</a>,
<a href="#screenHeight">screenHeight</a>. 
<p>

<b>setLocation(x, y, width, height)</b><br>
Moves and resizes the active image window. The new location of the top-left
corner is specified by <i>x</i> and <i>y</i>, and the
new size by <i>width</i> and <i>height</i>.
Requires v1.39e.
<p>

<b>setLut(reds, greens, blues)</b><br>
Creates a new lookup table and assigns it to the current image. Three input arrays are 
required, each containing 256 intensity values. See the

<a href="http://rsb.info.nih.gov/ij/macros/LookupTables.txt">LookupTables</a>
macros for examples.
<p>

<a name=setMetadata></a>
<b>setMetadata("Info", string)</b><br>
Assigns the metadata in <i>string</i> to the "Info"
image property of the current image.
This metadata is displayed by <i>Image&gt;Show Info</i> and
saved as part of the TIFF header.
See also: <a href="#getMetadata">getMetadata</a>. 
Requires v1.40b.
<p>

<b>setMetadata("Label", string)</b><br>
Sets <i>string</i> as the label of the current image or stack slice.
The first 60 characters, or up to the first newline, 
of the label are displayed as part of the image subtitle.
The labels are saved as part of the TIFF header.
See also: <a href="#getMetadata">getMetadata</a>. 
Requires v1.40b.
<p>

<b>setMinAndMax(min, max)</b><br>
Sets the minimum and maximum displayed pixel values (display range).
See the
<a href="http://rsb.info.nih.gov/ij/macros/DisplayRangeMacros.txt">DisplayRangeMacros</a>
for examples.
<p>

<b>setMinAndMax(min, max, channels)</b><br>
Sets the display range of specified channels in an RGB image,
where 4=red, 2=green, 1=blue, 6=red+green, etc.
Note that the pixel data is altered since RGB images, unlike
<a href="http://rsb.info.nih.gov/ij/docs/menus/image.html#make-composite">composite color images</a>,
do not have a LUT for each channel. Requires v1.42d.
<p>

<a name=setOption></a>
<b>setOption(option, boolean)</b><br>
Enables or disables an ImageJ option, where <i>option</i> is one of the following options
and <i>boolean</i> is either <i>true</i> or <i>false</i>.
 <p>
<i> "DisablePopupMenu"</i> enables/disables the the menu displayed when
you right click on an image.
 <i>"Show All"</i> enables/disables
 the ROI Manager's "Show All" mode.
<i>"Changes"</i> sets/resets the 'changes' flag of the current image.
 Set <i>"DebugMode"</i> true to put ImageJ in debug mode.
 <p>
 <i>"OpenUsingPlugins"</i>, added in v1.38f,
 controls whether standard file types (TIFF, JPEG, GIF, etc.) are opened by external
 plugins or by ImageJ
 (<a href="http://rsb.info.nih.gov/ij/macros/ToggleOpenUsingPlugins.txt">example</a>).
 <p>
 <i>"QueueMacros"</i>, added in v1.38g, controls whether macros invoked using keyboard shortcuts
 run sequentially on the event dispatch thread (EDT) or in separate, possibly concurrent, threads
  (<a href="http://rsb.info.nih.gov/ij/macros/DodgeBurnAndSmooth.txt">example</a>). 
  In "QueueMacros" mode, screen updates, which also run on the EDT, are delayed until the macro finishes.
  Note that "QueueMacros" does not work with macros
  using function key shortcuts in ImageJ 1.41g and earlier.
  <p>
  <i>"DisableUndo"</i>, added in v1.38h, enables/disables the <i>Edit&gt;Undo</i> command. Note
  that a <i>setOption("DisableUndo",true)</i> call without a corresponding <i>setOption("DisableUndo",false)</i> will cause 
  <i>Edit&gt;Undo</i> to not work as expected until ImageJ is restarted.
<p>
  <i>"Display Label"</i>, <i>"Limit to Threshold"</i>, <i>"Area"</i>,
  <i>"Mean"</i> and <i>"Std"</i>, added in v1.41,
  enable/disable the corresponding <i>Analyze&gt;Set Measurements</i> options.
<p>

<b>setPasteMode(mode)</b><br>
Sets the transfer mode used by the <i>Edit&gt;Paste</i> command, where 'mode' is "Copy", "Blend", "Average", "Difference", 
"Transparent", "AND", "OR", "XOR", "Add", "Subtract", "Multiply", or "Divide". In v1.37a or later, 'mode' can also be "Min" or "Max".
<p>

<b>setPixel(x, y, value)</b><br>
Stores <i>value</i> at location (<i>x,y</i>) of the current image. The screen is
updated when the macro exits or call updateDisplay() to have it updated immediately.
<p>

<a name=setResult></a>
<b>setResult("Column", row, value)</b><br>
Adds an entry to the ImageJ results table or modifies an existing entry. The first 
argument specifies a column in the table. If the specified column does not exist, it is added.
The second argument specifies the row, where 0&lt;=<i>row</i>&lt;=nResults.
(<i>nResults</i> is a predefined variable.) A row is added to the table if <i>row</i>=<i>nResults</i>. The third argument is the value to 
be added or modified. Call <i>setResult("Label", row, string)</i> to set the row label. 
Call <i>updateResults()</i> to display the updated table in the "Results" window.
For examples, see the

<a href="http://rsb.info.nih.gov/ij/macros/SineCosineTable.txt">SineCosineTable</a> and
<a href="http://rsb.info.nih.gov/ij/macros/ConvexitySolidarity.txt">ConvexitySolidarity</a> macros.
<p>

<a name=setRGBWeights></a>
<b>setRGBWeights(redWeight, greenWeight, blueWeight)</b><br>
Sets the weighting factors used by the <i>Analyze&gt;Measure</i>, <i>Image&gt;Type&gt;8-bit</i> 
and <i>Analyze&gt;Histogram</i> commands
when they convert RGB pixels values to grayscale. The sum of the weights must be 1.0. Use

<i>(1/3,1/3,1/3)</i> for equal weighting of red, green and blue.
The weighting factors in effect when the macro started are restored when it terminates.
For examples, see the
<a href="http://rsb.info.nih.gov/ij/macros/MeasureRGB.txt">MeasureRGB</a>,
<a href="http://rsb.info.nih.gov/ij/macros/ExtractRGBChannels.txt">ExtractRGBChannels</a> and
<a href="http://rsb.info.nih.gov/ij/macros/RGB_Histogram.txt">RGB_Histogram</a> macros.
<p>

<a name=setSelectionLocation></a>
<b>setSelectionLocation(x, y)</b><br>
Moves the current selection to <i>(x,y)</i>, where <i>x</i> and <i>y</i> are the pixel coordinates of the
upper left corner of the selection's bounding rectangle. The
<a href="http://rsb.info.nih.gov/ij/macros/RoiManagerMoveSelections.txt">RoiManagerMoveSelections</a>
macro uses this function to move all the ROI Manager selections a specified distance.
See also: <a href="#getSelectionBounds">getSelectionBounds</a>. 
<p>

<a name=setSelectionName></a>
<b>setSelectionName(name)</b><br>
Sets the name of the current selection to the specified name.
Aborts the macro if there is no selection.
See also:
<a href="#selectionName">selectionName</a> and
<a href="#selectionType">selectionType</a>. 
<p>

<a name=setSlice></a>
<b>setSlice(n)</b><br>
Displays the <i>n</i>th slice of the active stack. Does nothing if the active image is not a stack.
For an example, see the
<a href="http://rsb.info.nih.gov/ij/macros/MeasureStack.txt">MeasureStack</a>
macros.
See also: 
<a href="#getSliceNumber">getSliceNumber</a>, 
<a href="#nSlices">nSlices</a>.
<p>

<a name=setThreshold></a>
<b>setThreshold(lower, upper)</b><br>
Sets the lower and upper threshold levels. The values are uncalibrated 
except for 16-bit images (e.g., unsigned 16-bit images).
 Starting with v1.34g, there is an
optional third argument that can be "red", "black & white", "over/under" or "no color".
See also: 
<a href="#setAutoThreshold">setAutoThreshold</a>, 
<a href="#getThreshold">getThreshold</a>, 
<a href="#resetThreshold">resetThreshold</a>.
<p>

<a name=setTool></a>
<b>setTool(name)</b><br>
Switches to the specified tool, where <i>name</i> is "rectangle", "elliptical", "brush", "polygon", "freehand",
"line", "polyline", "freeline", "angle", "point", "wand", "text", "zoom", "hand" or
"dropper".
Refer to the
<a href="http://rsb.info.nih.gov/ij/macros/SetToolDemo.txt">SetToolDemo</a>
macro for an example. Requires 1.39l.
<p>

<a name=setTool></a>
<b>setTool(id)</b><br>
Switches to the specified tool, where 0=rectangle, 1=oval, 2=polygon, 3=freehand,
4=straight line, 5=polyline, 6=freeline, 7=point, 8=wand, 9=text, 10=spare,
11=zoom, 12=hand, 13=dropper, 14=angle, 15...21=spare.
See also: 
<a href="#toolID">toolID</a>.
<p>

<b>setupUndo()</b><br>
Call this function before drawing on an image to allow the user the option of later restoring the original image
using <i>Edit/Undo</i>. Note that setupUndo() may not work as intended
with macros that call the run() function.
For an example, see the
<a href="http://rsb.info.nih.gov/ij/macros/tools/DrawingTools.txt">DrawingTools</a>
tool set.
<p>

<a name=setVoxelSize></a>
<b>setVoxelSize(width, height, depth, unit)</b><br>
Defines the voxel dimensions and unit of length ("pixel", "mm", etc.) for the current 
image or stack. The <i>depth</i> argument is ignored if the current image is not a stack.
See also: <a href="#getVoxelSize">getVoxelSize</a>.
<p>

<b>setZCoordinate(z)</b><br>
Sets the Z coordinate used by <i>getPixel()</i>, <i>setPixel()</i> and <i>changeValues()</i>. The argument must 
be in the range 0 to n-1, where n is the number of images in the stack. For an examples, see the
<a href="http://rsb.info.nih.gov/ij/macros/tools/ZProfileTool.txt">Z Profile Plotter Tool</a>. 
<p>

<a name=showMessage></a>
<b>showMessage("message")</b><br>
Displays "message" in a dialog box.
<p>

<b>showMessage("title", "message")</b><br>
Displays "message" in a dialog box using "title" as the
the dialog box title.
<p>

<b>showMessageWithCancel(["title",]"message")</b><br>
Displays "message" in a dialog box with "OK" and "Cancel" buttons.
"Title" (optional) is the dialog box title. The macro exits if 
the user clicks "Cancel" button.

<p>

<b>showProgress(progress)</b><br>
Updates the ImageJ progress bar, where 0.0<=<i>progress</i>&lt;=1.0. The progress bar is 
not displayed if the time between the first and second calls to this function
is less than 30 milliseconds. It is erased when the macro terminates 
or <i>progress</i> is &gt;=1.0.
<p>

<b>showStatus("message")</b><br>
Displays a message in the ImageJ status bar.

<p>

<b>sin(angle)</b><br>
Returns the sine of an angle (in radians).
<p>

<a name=snapshot></a>
<b>snapshot()</b><br>
Creates a backup copy of the current image that can be later restored using the
<a href="#reset">reset</a> function.
For examples, see the
<a href="http://rsb.info.nih.gov/ij/macros/ImageRotator.txt">ImageRotator</a> and

<a href="http://rsb.info.nih.gov/ij/macros/BouncingBar.txt">BouncingBar</a> macros.
<p>

<b>split(string, delimiters)</b><br>
Breaks a string into an array of substrings. <i>Delimiters</i> is a string containing 
one or more delimiter characters. The default delimiter set " \t\n\r" (space, tab, newline, return) 
is used if <i>delimiters</i> is an empty string or split is called with only one argument. 
Returns a one element array if no delimiter 
is found.
<p>

<b>sqrt(n)</b><br>
Returns the square root of <i>n</i>. Returns NaN if <i>n</i> is less than zero.
<p>

<a name=Stack></a>
 <b>Stack (hyperstack) Functions</b><br>
These functions allow you to get and set the position (channel, slice and frame) 
of a hyperstack (a 4D or 5D stack).
The <a href="http://rsb.info.nih.gov/ij/macros/HyperStackDemo.txt">HyperStackDemo</a>
demonstrates how to create a hyperstack and how to work with it using these functions
Requires 1.39l.
<p>
<blockquote>

<b>Stack.isHyperstack</b> - 
Returns true if the current image is a hyperstack.
<br>

<b>Stack.getDimensions(width, height, channels, slices, frames)</b>
Returns the dimensions of the current image.
<br>

<b>Stack.setDimensions(channels, slices, frames)</b> - 
Sets the 3rd, 4th and 5th dimensions of the current stack.
<br>
	
<b>Stack.setChannel(n)</b> - 
Displays channel <i>n</i> .
<br>

<b>Stack.setSlice(n)</b> - 
Displays slice <i>n</i> .
<br>

<b>Stack.setFrame(n)</b> - 
Displays frame <i>n</i> .
<br>

<b>Stack.getPosition(channel, slice, frame)</b> - 
Returns the current position.
<br>

<b>Stack.setPosition(channel, slice, frame)</b> - 
Sets the position.
<br>

<b>Stack.getFrameRate()</b> - 
Returns the frame rate (FPS).
<br>

<b>Stack.setFrameRate(fps)</b> - 
Sets the frame rate.
<br>

<b>Stack.setDisplayMode(mode)</b> - 
Sets the display mode, where <i>mode</i> is "composite", "color" or "grayscale".
Requires a multi-channel stack and v1.40a or later.
<br>

<b>Stack.getDisplayMode(mode)</b> - 
Sets the string <i>mode</i> to the current display mode.
Requires v1.40a.
<br>

<b>Stack.setActiveChannels(string)</b> - 
Sets the active channels in a composite color image, where <i>string</i>
is a list of ones and zeros that specify the channels to activate.
For example, "101" activates channels 1 and 3.
Requires v1.41b.
<br>

<b>Stack.swap(n1, n2)</b> - 
Swaps the two specified stack images, where <i>n1</i> and <i>n2</i>
are integers greater than 0 and less than or equal to <a href="#nSlices">nSlices</a>.
Requires v1.40c.
<br>

<p>

</blockquote>

<a name=startsWith></a>
<b>startsWith(string, prefix)</b><br>
Returns <i>true</i> (1) if <i>string</i> starts with <i>prefix</i>.
See also: 
<a href="#endsWith">endsWith</a>, 
<a href="#indexOf">indexOf</a>,
<a href="#substring">substring</a>, 
<a href="#toLowerCase">toLowerCase</a>,
<a href="#matches">matches</a>. 
<p>

<a name=String></a>
 <b>String Functions</b><br>
These functions do string buffering and copy strings to and from
the system clipboard. The
<a href="http://rsb.info.nih.gov/ij/macros/CopyResultsToClipboard.txt">CopyResultsToClipboard</a>
macro demonstrates their use.
Requires 1.38r.
<blockquote>

<b>String.resetBuffer</b> - 
Resets (clears) the buffer.
<br>

<b>String.append(str)</b> - 
Appends <i>str</i> to the buffer.
<br>

<b>String.buffer</b> - 
Returns the contents of the buffer.
<br>

<b>String.copy(str)</b> - 
Copies <i>str</i> to the clipboard.
<br>

<b>String.copyResults</b> - 
Copies the Results table to the clipboard.
<br>

<b>String.paste</b> - 
Returns the contents of the clipboard.
<br>

</blockquote>

<a name=substring></a>
<b>substring(string, index1, index2)</b><br>
Returns a new string that is a substring of <i>string</i>. The 
substring begins at <i>index1</i> and extends to the character at <i>index2</i> - 1. 
See also: 
<a href="#indexOf">indexOf</a>,
<a href="#startsWith">startsWith</a>,
<a href="#endsWith">endsWith</a>,
<a href="#replace">replace</a>.
<p>

<b>substring(string, index)</b><br>
Returns a substring of <i>string</i> that
begins at <i>index</i> and extends to the end of <i>string</i>. 
Requires v1.41i.
<p>

 <b> T  </b><a name = T><a href='#Top'>[&nbsp;Top&nbsp;]</a><p>
<b>tan(angle)</b><br>
Returns the tangent of an angle (in radians).
<p>

<a name=toBinary></a>
<b>toBinary(number)</b><br>

Returns a binary string representation of <i>number</i>.
<p>

<a name=toHex></a>
<b>toHex(number)</b><br>
Returns a hexadecimal string representation of <i>number</i>.
<p>

<a name=toLowerCase></a>
<b>toLowerCase(string)</b><br>
Returns a new string that is a copy of <i>string</i> with all the characters converted to lower case.
<p>

<a name=toolID></a>
<b>toolID</b><br>
Returns the ID of the currently selected tool.
See also: <a href="#setTool">setTool</a>. 
<p>

<a name=toString></a>
<b>toString(number)</b><br>
Returns a decimal string representation of <i>number</i>.
See also: 
<a href="#toBinary">toBinary</a>,
<a href="#toHex">toHex</a>,
<a href="#parseFloat">parseFloat</a> and
<a href="#parseInt">parseInt</a>.
<p>

<b>toString(number, decimalPlaces)</b><br>
Converts <i>number</i> into a string, 
using the specified number of decimal places.
Requires v1.39r.
<p>

<b>toUpperCase(string)</b><br>
Returns a new string that is a copy of <i>string</i> with all the characters converted to upper case.
<p>


 <b> U  </b><a name = U><a href='#Top'>[&nbsp;Top&nbsp;]</a><p>
<b>updateDisplay()</b><br>
Redraws the active image.
<p>

<b>updateResults()</b><br>
Call this function to update the "Results" window after the results table has been 
modified by calls to the setResult() function.
<p>

<a name=V></a><a name=X></a><a name=Y></a><a name=Z></a>
 <b> W  </b><a name = W><a href='#Top'>[&nbsp;Top&nbsp;]</a><p>
<b>wait(n)</b><br>
Delays (sleeps) for <i>n</i> milliseconds.
<p>

<a name=waitForUser></a>
<b>waitForUser(string)</b><br>
Halts the macro and displays <i>string</i> in a dialog box. The macro proceeds when the 
user clicks "OK".
Unlike <a href="#showMessage">showMessage</a>, the dialog box is not modal,
so the user can, for example,
create a selection or adjust the threshold while the dialog is open.
To display a multi-line
message, add newline characters ("\n") to <i>string</i>. 
This function is based on 
Michael Schmid's
<a href="http://imagejdocu.tudor.lu/imagej-documentation-wiki/plugins/wait_for_user">Wait_For_User</a> plugin.
Example:
<a href="http://rsb.info.nih.gov/ij/macros/WaitForUserDemo.txt">WaitForUserDemo</a>.
Requires v1.39r.
<p>

<b>waitForUser(title, message)</b><br>
This is a two argument version of <a href="#waitForUser">waitForUser</a>, where <i>title</i> is the dialog box title
and <i>message</i> is the text dispayed in the dialog.
<p>

<b>write(string)</b><br>
Outputs a string to the "Results" window. Numeric arguments are automatically converted to strings.
<p>

</blockquote>

<p class=navbar> <a href="functions.html">top</a> | <a href="../../index.html">home</a> | <a href="../../notes.html">news</a> | <a href="../../docs/index.html">docs</a> | <a href="../../download.html">download</a> | <a href="../../plugins/index.html">plugins</a> | <a href="../index.html">dev</a> | <a href="../../search.html">search</a> | <a href="../../links.html">links</a></p>

</body>
</html>
